<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>块级作用域2</title>
	</head>
	<body>
		
		
		<button class="btns">按钮1</button>
		<button class="btns">按钮2</button>
		<button class="btns">按钮3</button>
	<script>
		var oBtns = document.getElementsByClassName("btns");
		for (let i in oBtns) {
			oBtns[i].onclick = () =>  alert(i)
		}
	</script>
	</body>
</html>
